﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.hunter
{
    public partial class hemplist : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["webid"] != null)
                {
                    int atid = Convert.ToInt32(Application["webid"]);
                    this.Title = string.Format("{1}猎头网   {1}人才网   {1}招聘网   {1}求职网  {0}", Application["webname"].ToString(), Application["webregion"].ToString());
                    BindAscx(atid);
                }
                if (Request["enterprise_rid"] != null)
                {
                    int rid = Convert.ToInt32(Request["enterprise_rid"]);
                    BindLeftInfo(rid);
                }
                else
                {
                    if (Application["webid"] != null)
                    {
                        int atid = Convert.ToInt32(Application["webid"]);

                        int c_isfrist = 0;
                        int c_reward = 0;
                        int c_vip = 0;
                        int c_hunter = 0;
                        int c_newjob = 0;
                        int c_workerclass = 0;
                        DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetJobsInfo(false, false, true, false, false, false,
                                                            atid, 1, 1,
                                                            out c_isfrist, out c_reward, out c_hunter, out c_vip, out c_newjob, out c_workerclass);
                        if (ds.Tables[0].Rows.Count == 1)
                        {

                            this.Response.Redirect("hemplist-" + ds.Tables[0].Rows[0]["enterprise_rid"] + ".html");
                        }
                    }
                }
            }
        }

        protected void Button4_Clicrk(object sender, EventArgs e)
        {
            /*
            if (Session["user_id"] != null)
            {
                if (lblid.Text.Trim() != "")
                {
                    try
                    {
                        lcmyjobs.BLL.user_basic bub = new BLL.user_basic();
                        int uid = int.Parse(Session["user_id"].ToString());
                        int id = int.Parse(lblid.Text);
                        int rowa = 0;
                        if (bub.adduserhunter(uid, id, out rowa) == 1)
                        {
                            if (rowa > 0)
                            {
                                Maticsoft.Common.MessageBox.Show(this, "申请猎头职位成功！");

                            }
                            else
                                Maticsoft.Common.MessageBox.Show(this, "申请猎头职位失败！");


                        }
                        else
                            Maticsoft.Common.MessageBox.Show(this, "您已经申请过该职位！");

                    }
                    catch (Exception ex)
                    {
                        Maticsoft.Common.MessageBox.Show(this, "申请猎头职位失败！");
                    }
                }

            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "a", "if(confirm('您还没有登录！是否要登录？'))window.location='../users/userlogin.html'", true);
            }
             */
        }

        private void BindAscx(int atid)
        {
            this.GridHunterJobs1.isAspPager = true;
            this.GridHunterJobs1.atid = atid;
            this.GridHunterJobs1.disCount = 20;
        }

        private void BindLeftInfo(int enterprise_rid)
        {
            /*
            DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetBasicAndJobsInfoByRid(enterprise_rid);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                this.lbl_areaname.Text = row["area_name"].ToString();
                this.lbl_jobduty.Text = row["jobduty"].ToString();
                this.lbl_jobsname.Text = row["jobs_name"].ToString();
                this.lbl_salaryy.Text = row["salaryy"].ToString();
                this.lbl_validity.Text = row["validity"].ToString();
                this.lbl_requirement.Text = row["jobrequirement"].ToString();


            }
            if (ds.Tables[1].Rows.Count > 0)
            {
                DataRow row = ds.Tables[1].Rows[0];
                this.lbl_dwgm.Text = row["dwgm"].ToString();
                this.lbl_trade.Text = row["trade_name"].ToString();
            }
            if (ds.Tables[3].Rows.Count > 0)//获取猎头职位的主键
            {
                DataRow row = ds.Tables[3].Rows[0];

                this.lbl_bh.Text = "L" + row["enterprise_aid"].ToString().PadLeft(6, '0');//猎头职位编号为enterprise_askhunter表的主键
                this.lblid.Text = row["enterprise_aid"].ToString();//绑定enterprise_aid
            }
             * */
        }

        protected void btnxidan_Click(object sender, EventArgs e)
        {
            Response.Redirect("checkEnLogin.html");
        }
    }
}